<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_search
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
$id = 1;
$countries = $params->get('country');
$countries = explode(';',$countries);
//var_dump($countries);die;
?>
<div class="tpl-form gradient-1 clearfix">
	<form id="f-contact" name="f-contact" action="<?php echo JRoute::_('index.php'); ?>" method="post">
		<div class="input-block ip-col-2">
			<label for="">Firstname *</label>
			<input name="fname" id="fname" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2 col-last">
			<label for="">Lastname *</label>
			<input name="lname" id="lname" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2">
			<label for="">Title *</label>
			<input name="title" id="title" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2 col-last">
			<label for="">Company *</label>
			<input name="company" id="company" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2">
			<label for="">E-mail *</label>
			<input name="email" id="email" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2 col-last">
			<label for="">Phone no. *</label>
			<input name="phone" id="phone" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2">
			<label for="">Country *</label>
			<select class="f-select" name="country" id="country">
				<?php foreach($countries as $country): ?>
					<option value="<?php echo $country;?>"><?php echo $country; ?></option>
				<?php endforeach; ?>
			</select>
		</div>
		<div class="input-block ip-col-2 col-last">
			<label for="">State</label>
			<input name="state" id="state" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2">
			<label for="">Industry *</label>
			<input name="industry" id="industry" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="input-block ip-col-2 col-last">
			<label for="">Estimated # of nodes</label>
			<input name="node" id="node" type="text" class="f-input i-toggle" value="...">
		</div>
		<div class="clear"></div>
		<div class="input-block">
			<label for="">Your message</label>
			<textarea name="message" id="message" class="i-toggle">...</textarea>
		</div>
		<div class="clr"></div>
		<div class="form-submit clearfix">
			<a href="#" class="btnSend fll" onclick="jQuery('#f-contact').submit();" >Send</a>
		</div>
		<input type="hidden" name="option" value="com_contact" />
		<input type="hidden" name="task" value="contact.submit1" />
		<input type="hidden" name="return" value="" />
		<input type="hidden" name="id" value="<?php echo $id; ?>" />
		<?php echo JHtml::_( 'form.token' ); ?>
	</form>
</div>
<p id="p-field">* All fields are mandatory</p>
               
 <?php                        	       
$input_fname = JText::_( 'Enter Your First Name' );
$input_lname = JText::_( 'Enter Your Last Name' );
$input_title = JText::_( 'Enter Your Title' );
$input_company = JText::_( 'Enter Your Company' );
$input_phone = JText::_( 'Enter Your Phone' );
$input_email = JText::_( 'Enter Your Email' );
$input_country = JText::_( 'Enter Your Country' );
$input_industry = JText::_( 'Enter Your Industry' );
$input_node = JText::_( 'Enter Your Estimated nodes' );
$input_message = JText::_( 'Enter Your Message' );

	
?>                        
 <script type="text/javascript">                   
jQuery(document).ready(function(jQuery) {
	jQuery.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
	jQuery.validator.addMethod("notEqual", function(value, element, param) {
			return this.optional(element) || value !== param;
	});
		//jQuery("#postcode").mask("9999",{placeholder:""});  
		jQuery('#f-contact').validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				jQuery('#alert').html(validator['errorList'][0]['message']);
    			jQuery('#backoverlay').show();
    			jQuery('#show_popup').show();
            	jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				
			  } else {
			  }
			},
			rules: {
				fname:{
					required: true,
					notEqual: "...",
				},
				lname:{
					required: true,
					notEqual: "...",
				},
				title:{
					required: true,
					notEqual: "...",
				},
				company:{
					required: true,
					notEqual: "...",
				},	
				email:{
					required: true,
					email: true,
					notEqual: "...",
				},	
				phone:{
					required: true,
					digits:true,
					minlength:6,
					notEqual: "...",
				},
				country:{
					required: true,
					notEqual: "...",
				},
				industry:{
					required: true,
					notEqual: "...",
				},
				node:{
					required: true,
					notEqual: "...",
				},
				message:{
					required: true,
					notEqual: "...",
				},
			},
			messages: {
				fname: "<?php echo $input_fname; ?>",
				lname: "<?php echo $input_lname; ?>",
				title: "<?php echo $input_title; ?>",
				company: "<?php echo $input_company; ?>",
				email: "<?php echo $input_email; ?>",
				phone: "<?php echo $input_phone; ?>",
				country: "<?php echo $input_country; ?>",
				industry: "<?php echo $input_industry; ?>",
				node: "<?php echo $input_node; ?>",
				message: "<?php echo $input_message; ?>",
				
			
			}
		});
        close_popup=function(){		
			var fel=jQuery('#f_focus').html();
            jQuery('#backoverlay').hide();
    		jQuery('#show_popup').hide();
    		jQuery('#' + fel ).focus();		
      };
      
      
	});
</script>


